package Tree;

import java.util.List;

public class p559N叉树的最大深度 {
    class Solution {
        public int maxDepth(Node root) {
            if(root == null) return 0;
            int depth = 0;
            for(int i = 0; i < root.children.size(); i++){
                depth = Math.max(depth, maxDepth(root.children.get(i)));
            }
            return depth + 1;
        }
    }

    class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    };
}
